<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户修改</title>

<script type="text/javascript" src="../js/jquery-3.4.1/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../js/bootstrap-4.4.1-dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../js/bootstrap-4.4.1-dist/css/bootstrap.min.css">

<style type="text/css">
.card {
	width: 95%;
	margin: 0 auto;
}

.card-body {
	width: 50%;
	margin: 0 auto;
}
</style>

<script type="text/javascript">
	$(function() {
		$("form").submit(function() {
			var pwd1 = $("input[name='userPwd']").val();
			var pwd2 = $("input[name='userPwd2']").val();
			if (pwd1 != pwd2) {
				alert("两次输入的密码不一致！");
				return false;
			}
			var phone = $("input[name='userPhone']").val();
			if (!(/^1\d{10}$/.test(phone))) {
				alert("请输入正确的手机号！");
				return false;
			}
		});
	});
</script>

</head>
<body>
	<div class="card shadow">
		<div class="card-body">
			<form action="updateUser.do" method="post">
				<div class="form-group">
					<label for="userId">用户ID：</label>
					<input type="text" class="form-control" name="userId" id="userId" readonly="readonly"
						value="${user.userId }">
				</div>
				<div class="form-group">
					<label for="userAccount">用户账号：</label>
					<input type="text" class="form-control" name="userAccount" id="userAccount" readonly="readonly"
						value="${user.userAccount }">
				</div>
				<div class="form-group">
					<label for="userPwd">用户密码：</label>
					<input type="password" class="form-control" name="userPwd" id="userPwd"
						value="${user.userPwd }" required="required">
				</div>
				<div class="form-group">
					<label for="userPwd2">确认密码：</label>
					<input type="password" class="form-control" name="userPwd2" id="userPwd2"
						value="${user.userPwd }" required="required">
				</div>
				<div class="form-group">
					<label for="userPhone">用户手机号：</label>
					<input type="text" class="form-control" name="userPhone" id="userPhone"
						value="${user.userPhone }" required="required">
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-success">修改</button>
					<button type="button" class="btn btn-secondary" onclick="goBack()">返回</button>
				</div>
			</form>
		</div>
	</div>
	<c:if test="${msg!=null }">
		<script type="text/javascript">
			alert("${msg}");
		</script>
	</c:if>
</body>

<script type="text/javascript">
	function goBack() {
		location.href = "getAllUser.do";
	}
</script>
</html>